package com.settlement.system.rules;

import com.settlement.system.model.entity.SysAudit;
import com.settlement.system.model.entity.SysAuditRule;

import java.math.BigDecimal;

/**
 * 6、已退款已退货
 * （已退货已退款且系统平库存）
 */
public class ReturnGoodsReturnMoneyRuler implements CommonRuler {
    @Override
    public boolean check(SysAudit sysAudit, SysAuditRule auditRule) {
        // "应收账余额=0
        //且收款金额=0
        //且退款+保证金退款<0
        //且退货金额＜0
        //且退款金额+保证金退款金额-退货金额=0
        //且发货数量+退货数量+系统调账数量=0"
        return BigDecimal.ZERO.compareTo(sysAudit.getReceiveBillAmount()) == 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getReceiveAmount()) == 0 &&
                sysAudit.getRefundAmount().add(sysAudit.getDepositAmount()).compareTo(BigDecimal.ZERO) < 0 &&
                sysAudit.getReturnAmount().compareTo(BigDecimal.ZERO) < 0 &&
                BigDecimal.ZERO.compareTo(sysAudit.getRefundAmount().add(sysAudit.getDepositAmount()).subtract(sysAudit.getReturnAmount())) == 0 &&
                sysAudit.getQty() + sysAudit.getReturnQty() + sysAudit.getSystemReconciliationQty() == 0;
    }
}
